//
//  MenuSubView.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/1/30.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "MenuSubView.h"

@implementation MenuSubView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if(self)
    {
        //顶部
        _icon = [[UIImageView alloc] init];
        [self addSubview:_icon];
        
        //标题
        _title = [[UILabel alloc] init];
        [self addSubview:_title];
        
        //描述
        _describe = [[UILabel alloc] init];
        [self addSubview:_describe];
        [_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
        }];
        
        [_describe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
        }];
//        NSArray *controlArr = @[_icon,_title,_describe];
//        [controlArr mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing:1 leadSpacing:1 tailSpacing:1];
        _icon.contentMode = UIViewContentModeScaleAspectFit;
        [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@35);
            make.height.equalTo(@35);
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(10);
        }];
        
        _title.font = DEFAULT_FONT(11);
        [_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(_icon.mas_bottom).offset(5);
            make.height.equalTo(@13);
        }];
        
        _describe.font = DEFAULT_FONT(11);
        [_describe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(_title.mas_bottom).offset(3);
            make.height.equalTo(@13);
        }];
        
        
    }
    
    
    _clickButton = [[UIButton alloc] initWithFrame:self.bounds];
    [self addSubview:_clickButton];
    return self;
}

-(void)initWithImage:(UIImage *)image AndTitle:(NSString *)title AndTip:(NSString *)tip
{
    [_icon setImage:image];
    _title.text = title;
    _describe.text = tip;
}

+(MenuSubView *)initWithImage:(UIImage *)image AndTitle:(NSString *)title AndTip:(NSString *)tip
{
    MenuSubView *view = [[MenuSubView alloc] initWithFrame:CGRectMake(0, 0, 60, 130)];
//    view.clickButton.frame = CGRectMake(0, 0, 60, 130);
    [view initWithImage:image AndTitle:title AndTip:tip];
//    view.backgroundColor = [UIColor yellowColor];
    return view;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
